<?php
/*
2007-06-24 no static info
*/
////////////////////////////////////////////////////////
/// POwered By Man\/Machine  :: CounterAct|*|Design  ::
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////

require('includes/application_top.php');


///////////////////////////////////////////////////

// Fonction pour parser les variables vers FLASH
/////////
   function Parse($variable,$valeur) {
       echo "&" . $variable . "=" . urlencode($valeur);
   }

// Fonction pour trouver les fichiers
/////////
function tep_browse_mp3($pDirectory, $pExtension)
{
    if($handle = opendir($pDirectory))
    {
         while(false !== ($file = readdir($handle)))
        {
            $getExt = explode(".", $file);
            $countExt = count($getExt);
            $fExt = $countExt - 1;
            $myExt = $getExt[$fExt];
            
            if (($myExt == $pExtension) && ($file != ".") && ($file != ".."))
                {$files[] = $file;}
        }
    }
return $files;    
closedir($handle);
}
/////////////////////////////////////////////////                              
$mp3id=$HTTP_POST_VARS['idmp3'];
$mp3_files_query = tep_db_query("select products_folder from " . TABLE_PRODUCTS_MP3 . " where  products_id = '" . $mp3id . "'");
$mp3_files = tep_db_fetch_array($mp3_files_query);



$gDirectory = DIR_FS_CATALOG_MP3 . $mp3_files['products_folder'] ; // � �diter
$gExtension = "mp3"; // s�parez les extensions par un espace

$ExpExt = explode(" ", $gExtension);
sort ($ExpExt);

foreach ($ExpExt as $findExt) {
        
		$getFile = @tep_browse_mp3($gDirectory, $findExt);
        $countFile = count($getFile);      
        
        if ($countFile != 0) { 
			foreach ($getFile as $myFile) {
				$list[] = $myFile;
			}  
		}            
    } 

// sort playlist properly
$$list = array();
sort($list);

/// vers flash

for($i=0;$i<$countFile;$i++) {
$trck[$i] = "$list[$i]";
Parse ("trck$i" , $trck[$i] ) ;
}

//$path = DIR_FS_CATALOG_MP3 . $mp3_files['products_name'] ;
$path = DIR_WS_CATALOG_MP3 . $mp3_files['products_folder'] ;
$trcknbr = $countFile ;
Parse ("path" , $path ) ;
Parse ("trcknbr" , $trcknbr ) ;


?>